# 模拟缓存对象池
context_cache = {}

# 缓存写入函数
def store_context(session_id, prompt_block):
    context_cache[session_id] = {
        "content": prompt_block,
        "version": "v1.0",
        "timestamp": "2025-04-10T12:00:00Z"
    }
# 缓存读取函数
def load_context(session_id):
    return context_cache.get(session_id, None)
# 写入一段上下文缓存
session_id = "session_user_123"
prompt_structure = [
    {"role": "system", "content": "你是一个项目管理助手"},
    {"role": "user", "content": "请帮我整理今天的会议重点"}
]
store_context(session_id, prompt_structure)
# 读取缓存并注入当前请求
cached = load_context(session_id)
if cached:
    print("成功命中缓存，已加载上下文：")
    for p in cached["content"]:
        print(f"- {p['role']}：{p['content']}")
else:
    print("无可用上下文缓存")